/**
 * made by Maowl
 */

(function($){
    $.fn.picPortionResize = function(options_events){
		var opts = $.extend({}, 
							{	
								/*options*/
								width: 100,
								maxHeight: 100,
								keepSmaller: false
							},
							options_events);
							
		var picPortionResizeNameSpace = {
			
		};
		
		return $(this).each(function(){
			var newImg = new Image();
			newImg.src = $(this)[0].src
			if(!(newImg.width < opts.width && opts.keepSmaller)){
				var resizeWidth = opts.width;		
				var resizeHeight = newImg.height / newImg.width * resizeWidth;
				if(resizeHeight > opts.maxHeight){
					resizeHeight = opts.maxHeight;
				}
				
				$(this).css('width', resizeWidth);
				$(this).css('height', resizeHeight);
			}
		});
	};
})(window.jQuery);